<?php

namespace Xsjosg\Zt\App\Webapp\Sixyear251014;

use Xsjosg\Zt\Core\Controllers\ApiController;
use Xsjosg\Zt\App\Webapp\Sixyear251014\Providers\LogicServiceProvider;

/**
 * 库洛6周年活动
 *
 * @author tanjiancheng <tanjianchengcc@gmail.com>
 */
class Controller extends ApiController
{
    public function __construct()
    {
        parent::__construct();
        app()->register(LogicServiceProvider::class);
        // 如不需要全局检查活动状态,可删除此代码
        app('checker')->checkActivityStatusGlobal([
            // 不检查的action
        ]);
    }

    /**
     * 网页端官渠用户登录、游戏内静默登录
     *
     * <pre>
     * params:
     *   username: 登录sdk的phoneCode.lg验证过后返回的username
     *   cuid: 登录sdk的phoneCode.lg验证过后返回的cuid
     *   token: 登录sdk的getToken.lg验证过后返回的access_token
     * data{}:
     *   user_info: 用户登录信息
     * data{}.user_info{}:
     *   name: 用户名
     *   uid: 账号uid
     * remark_before_md: |
     * remark_after_md: |
     * example_request: |
     *   http://<domain>/webapp/sixyear251014/login_by_sdk?username=U517273975A&cuid=507273975&token=501f683d-f1a7-3bfa-80af-b0f996054cc2
     * example_response: |
     *   {
     *       "code": 1,
     *       "status": 1,
     *       "msg": "",
     *       "message": "",
     *       "data": {
     *           "user_info": {
     *               "name": "U517273975A",
     *               "uid": "507273975"
     *           },
     *           "session_id": "yn2aK5St5zSAyNJcEbGpILTMOUwV3aCLIeCrj7wJ",
     *           "request_id": "9e8b9fec09435f69e49e4d746c0b6d9d7b95cf0f"
     *       }
     *   }
     * </pre>
     */
    public function loginBySdkAction()
    {
        $data = app('logic')->loginBySdk(app('request')->input());
        return app('logic')->makeJsonpResponse(1, '', $data);
    }


    /**
     * 街区登录
     *
     * <pre>
     * params:
     *   token: sdk登录后返回的token
     * data{}:
     *   accessToken: accessToken
     *   user_info: 用户登录信息
     * data{}.user_info{}:
     *   name: 用户名称
     *   uid: 账号uid
     * remark_before_md: |
     * remark_after_md: |
     * example_request: |
     *   http://<domain>/webapp/sixyear251014/login_kjq
     * example_response: |
     *   {
     *       "code": 1,
     *       "status": 1,
     *       "msg": "",
     *       "message": "",
     *       "data": {
     *           "user_info": {
     *               "name": "",
     *               "uid": "508458321"
     *           },
     *           "accessToken": "85ba9967-494b-3c09-bcb6-fc75b0a21eb7",
     *           "session_id": "JdhQQDF474qleniT4IzUmRnhFbCHcjwkBRFaAUP8",
     *           "request_id": "84094ae3b11f95ff46d1893d6d3baaccf4472d2b"
     *       }
     *   }
     * </pre>
     */
    public function loginKjqAction()
    {
        $data = app('logic')->loginKjq(app('request')->input());
        return app('logic')->makeJsonpResponse(1, '', $data);
    }

    /**
     * 网页端渠道用户登录（角色ID登录）
     *
     * <pre>
     * params:
     *   token: sdk登录后返回的token
     * data{}:
     *   user_info: 用户登录信息
     * data{}.user_info{}:
     *   name: 角色名称
     *   uid: 账号uid
     * remark_before_md: |
     * remark_after_md: |
     * example_request: |
     *   http://<domain>/webapp/sixyear251014/login_by_uid?token=xxxxxxx
     * example_response: |
     *   {
     *       "code": 1,
     *       "status": 1,
     *       "msg": "",
     *       "message": "",
     *       "data": {
     *           "user_info": {
     *               "name": "test",
     *               "uid": "10377593"
     *           },
     *           "session_id": "Xmc2NVELkETLMYWjylVZ04hjQYaeKSD6WIrqcu5g",
     *           "request_id": "f0f05c2ac65b3c9691b004e44c4638a22684fe9e"
     *       }
     *   }
     * </pre>
     */
    public function loginByUidAction()
    {
        $data = app('logic')->loginByUid(app('request')->input());
        return app('logic')->makeJsonpResponse(1, '', $data);
    }

    /**
     * 获取服务器列表 (用于login_by_sdk拉取区服列表)
     *
     * <pre>
     * params:
     * data{}:
     *   list: 列表
     * data{}.list[]:
     *   name: 服务器名称
     *   value: 服务器值
     * remark_before_md: |
     * remark_after_md: |
     * example_request: |
     *   http://<domain>/webapp/sixyear251014/get_server_list
     * example_response: |
     *   {
     *       "code": 1,
     *       "status": 1,
     *       "msg": "",
     *       "message": "",
     *       "data": {
     *           "list": [
     *               {
     *                   "name": "testServer",
     *                   "value": 500
     *               }
     *           ],
     *           "session_id": "4QgQ7esZ93FUdqxwwm5zTOrmsJqna9GTT8ZrrvAv",
     *           "request_id": "5d86b961e43512d2a7e971714c96268a21e5acf0"
     *       }
     *   }
     * </pre>
     */
    public function getServerListAction()
    {
        $data = app('logic')->getServerList(app('request')->input());
        return app('logic')->makeJsonpResponse(1, '', $data);
    }

    /**
     * 选择区服后登录
     *
     * <pre>
     * params:
     *   server_id: 服id
     * data{}:
     *   user_info: 用户登录信息
     * data{}.user_info{}:
     *   name: 服务器名称
     *   uid: 账号uid
     * remark_before_md: |
     *   /webapp/sixyear251014/login_by_sdk登录后调用
     * remark_after_md: |
     * example_request: |
     *   http://<domain>/webapp/sixyear251014/login_by_server_id?server_id=500
     * example_response: |
     *   {
     *       "code": 1,
     *       "status": 1,
     *       "msg": "",
     *       "message": "",
     *       "data": {
     *           "user_info": {
     *               "name": "test",
     *               "uid": "test1"
     *           },
     *           "session_id": "oxWVJsbvswmp7j8hRnX8Re0Yo8j9Dh5wGHljQdqS",
     *           "request_id": "7a85e66ac8e3e2bc73092d430cd444f01f2eb51e"
     *       }
     *   }
     * </pre>
     */
    public function loginByServerIdAction()
    {
        $data = app('logic')->loginByServerId(app('request')->input());
        return app('logic')->makeJsonpResponse(1, '', $data);
    }


    /**
     * 库街区内选择角色后登录
     *
     * <pre>
     * params:
     *   server_id: 服id
     *   role_id: 角色id
     *   role_name: 角色名称
     * data{}:
     *   user_info: 用户登录信息
     * data{}.user_info{}:
     *   name: 角色名称
     *   uid: 账号uid
     * remark_before_md: |
     *   /webapp/sixyear251014/login_kjq 后调用
     * remark_after_md: |
     * example_request: |
     *   http://<domain>/webapp/sixyear251014/login_by_role_id_and_server_id?server_id=1000&role_id=1000&role_name=test
     * example_response: |
     *   {
     *       "code": 1,
     *       "status": 1,
     *       "msg": "",
     *       "message": "",
     *       "data": {
     *           "user_info": {
     *               "name": test,
     *               "uid": "test1"
     *           },
     *           "session_id": "X3qYWwojWkT58RhUG37A1Nr6wlCbNtr9jv2v3VnE",
     *           "request_id": "031b85511b8201d016688f08c4bb816054dbf387"
     *       }
     *   }
     * </pre>
     */
    public function loginByRoleIdAndServerIdAction()
    {
        $data = app('logic')->loginByRoleIdAndServerId(app('request')->input());
        return app('logic')->makeJsonpResponse(1, '', $data);
    }

    /**
     * 获取当前登录用户信息
     *
     * <pre>
     * params:
     * data{}:
     *   user: 用户信息
     * data{}.user{}:
     *   channel_id: 渠道id
     *   role_id: 角色id
     *   role_name: 角色昵称
     *   server_id: 服id
     *   user_id: 用户id
     * remark_before_md: |
     *   当前如果没有登录，请调用合适的方式先登录
     * remark_after_md: |
     * example_request: |
     *   http://<domain>/webapp/sixyear251014/get_current_user
     * example_response: |
     *   {
     *       "code": 1,
     *       "status": 1,
     *       "msg": "",
     *       "message": "",
     *       "data": {
     *           "user": {
     *               "user_id": "user_id",
     *               "role_id": "role_id",
     *               "server_id": "400",
     *               "role_name": "cc",
     *               "channel_id": "111"
     *           },
     *           "session_id": "997ritNG5rBGe2AqTd6mzEbzMQB9Lvu5Z5q5fx5G",
     *           "request_id": "98bf0ed7fd1dee626f8e5bf067e058863303c1ae"
     *       }
     *   }
     * </pre>
     */
    public function getCurrentUserAction()
    {
        $data = app('logic')->getCurrentUser(app('request')->input());
        return app('logic')->makeJsonpResponse(1, '', $data);
    }

    /**
     * 退出登录
     *
     * <pre>
     * params:
     * data{}:
     * remark_before_md: |
     * remark_after_md: |
     * example_request: |
     *   http://<domain>/webapp/sixyear251014/login_out
     * example_response: |
     *   {
     *       "code": 1,
     *       "status": 1,
     *       "msg": "",
     *       "message": "",
     *       "data": {
     *           "session_id": "oxWVJsbvswmp7j8hRnX8Re0Yo8j9Dh5wGHljQdqS",
     *           "request_id": "504c457f9edffbdd5d307747f37281b4e099d7b0"
     *       }
     *   }
     * </pre>
     */
    public function loginOutAction()
    {
        app('logic')->loginOut(app('request')->input());
        return app('logic')->makeJsonpResponse(1);
    }

    /**
     * 获取用户相关配置
     *
     * <pre>
     * params:
     * data{}:
     *   user_config: 用户相关配置
     * data{}.user_config{}:
     *   annual_report_reward: 周年回顾奖励 false没有领取 true已经领取
     *   share_reward: 分享奖励 false没有领取 true已经领取
     * remark_before_md: |
     *   登录后调用
     * remark_after_md: |
     * example_request: |
     *   http://<domain>/webapp/sixyear251014/get_user_config
     * example_response: |
     *   {
     *       "code": 1,
     *       "status": 1,
     *       "msg": "",
     *       "message": "",
     *       "data": {
     *           "user_config": {
     *               "share_reward": false,
     *               "annual_report_reward": false
     *           },
     *           "session_id": "tNfzqksV4PmJauZyeo5Y8WXxc3lXzmwJtiE6bw5O",
     *           "request_id": "70da97d84858f1d9f9c3f02a4a021ff7a474f875"
     *       }
     *   }
     * </pre>
     */
    public function getUserConfigAction()
    {
        $data = app('logic')->getUserConfig(app('request')->input());
        return app('logic')->makeJsonpResponse(1, '', $data);
    }

    /**
     * 查询玩家周年回顾数据
     *
     * <pre>
     * params:
     *   share_uid: 分享加密uid，从分享链接中获取，可为空，为空时，使用当前登录用户信息
     * data{}:
     *   review_data: 玩家周年回顾数据, 其他字段的请对应文档说明
     * data{}.review_data{}:
     *   assignSchedule: 按文档说明
     *   awarenessSchedule: 按文档说明
     *   awarenessTotalChapter: 按文档说明
     *   characterCount: 按文档说明
     *   createTimeStamp: 按文档说明
     *   existDayCount: 按文档说明
     *   fashionCollectPercent: 按文档说明
     *   guildName: 按文档说明
     *   headPortraitId: 按文档说明
     *   mainLineChapterId: 按文档说明
     *   mainLineStageId: 按文档说明
     *   mainLineStageName: 按文档说明
     *   maxAbility: 按文档说明
     *   maxAbilityCharacterId: 按文档说明
     *   maxTrustLvCharacterCount: 按文档说明
     *   maxTrustLvName: 按文档说明
     *   medalInfos: 按文档说明
     *   name: 角色名称
     *   onlineDayCount: 按文档说明
     *   partnerCount: 按文档说明
     *   reviewArenaChallenge: 按文档说明
     *   reviewBossSingle: 按文档说明
     *   reviewCharacter: 按文档说明
     *   reviewDraw: 按文档说明
     *   roleId: 按文档说明
     *   scoreTitleIdList: 按文档说明
     *   strongholdMaxGroupName: 按文档说明
     *   useActionPointCount: 按文档说明
     *   useCoinTotalCount: 按文档说明
     * data{}.review_data{}.medalInfos[]:
     *   id: 按文档说明
     *   time: 按文档说明
     * data{}.review_data{}.reviewDraw{}:
     *   drawAverageCount: 按文档说明
     *   drawMaxCount: 按文档说明
     *   drawMaxCountCharacterId: 按文档说明
     *   drawMinCount: 按文档说明
     *   drawMinCountCharacterId: 按文档说明
     * data{}.review_data{}.reviewCharacter{}:
     *   maxDormFondleMoodCharacter: 按文档说明
     *   maxDormFondleMoodCount: 按文档说明
     *   maxDormWorkCharacter: 按文档说明
     *   maxDormWorkCount: 按文档说明
     *   maxFightCharacter: 按文档说明
     *   maxFightCount: 按文档说明
     *   maxTouchCharacter: 按文档说明
     *   maxTouchCount: 按文档说明
     * data{}.review_data{}.reviewBossSingle{}:
     *   bossSingleMaxLevelName: 按文档说明
     *   bossSingleMaxScore: 按文档说明
     *   bossSingleMaxScoreBossName: 按文档说明
     *   bossSingleTotalScore: 按文档说明
     * data{}.review_data{}.reviewArenaChallenge{}:
     *   arenaHighestLevel: 按文档说明
     *   arenaSecondLevel: 按文档说明
     *   highestCount: 按文档说明
     *   secondCount: 按文档说明
     * remark_before_md: |
     *   登录后调用
     * remark_after_md: |
     * example_request: |
     *   http://<domain>/webapp/sixyear251014/query_player_review_data?share_uid=a5fb90d9e93f9eb8f6204b4a4134293f
     * example_response: |
     *   {
     *       "code": 1,
     *       "status": 1,
     *       "msg": "",
     *       "message": "",
     *       "data": {
     *           "review_data": {
     *               "roleId": 17621679,
     *               "name": "天河吴彦祖",
     *               "headPortraitId": 9090001,
     *               "createTimeStamp": 1575470117,
     *               "existDayCount": 1723,
     *               "guildName": "得闲吹下⽔",
     *               "mainLineChapterId": 31,
     *               "mainLineStageId": 19,
     *               "mainLineStageName": "寻找四叶草的阿呆蛙",
     *               "assignSchedule": "野滨岬空军基地",
     *               "awarenessSchedule": 6,
     *               "awarenessTotalChapter": 6,
     *               "maxAbilityCharacterId": 1041004,
     *               "maxAbility": 7748,
     *               "characterCount": 53,
     *               "maxTrustLvName": "熟悉",
     *               "maxTrustLvCharacterCount": 3,
     *               "partnerCount": 36,
     *               "medalInfos": [
     *                   {
     *                       "id": 1,
     *                       "time": 1592387207
     *                   },
     *                   {
     *                       "id": 3,
     *                       "time": 1676599919
     *                   },
     *                   {
     *                       "id": 4,
     *                       "time": 1698048408
     *                   },
     *                   {
     *                       "id": 2,
     *                       "time": 1699589890
     *                   },
     *                   {
     *                       "id": 6,
     *                       "time": 1721038600
     *                   }
     *               ],
     *               "scoreTitleIdList": [
     *                   13000001,
     *                   13000100,
     *                   13000600,
     *                   13006100,
     *                   13006800,
     *                   13007200,
     *                   13013004,
     *                   13019502,
     *                   13019401,
     *                   13019504,
     *                   13019501,
     *                   13000300,
     *                   13019601,
     *                   13019604,
     *                   13019603,
     *                   13013005,
     *                   13019602,
     *                   13000700,
     *                   13019608,
     *                   13019611,
     *                   13019619,
     *                   13019618,
     *                   13019621,
     *                   13019622,
     *                   13019623,
     *                   13019624,
     *                   13019626,
     *                   13019625,
     *                   13000500,
     *                   13019627,
     *                   13019628,
     *                   13019629,
     *                   13019630,
     *                   13019631,
     *                   13019638,
     *                   13019635,
     *                   13019639,
     *                   13019634,
     *                   13019641,
     *                   13019640,
     *                   13019645,
     *                   13019644,
     *                   13019647,
     *                   13019650,
     *                   13019651
     *               ],
     *               "fashionCollectPercent": "14.0%",
     *               "useActionPointCount": 78940,
     *               "useCoinTotalCount": 39934500,
     *               "onlineDayCount": 121,
     *               "reviewArenaChallenge": {
     *                   "arenaHighestLevel": "英雄",
     *                   "highestCount": 28,
     *                   "arenaSecondLevel": "领袖",
     *                   "secondCount": 24
     *               },
     *               "reviewCharacter": {
     *                   "maxDormFondleMoodCharacter": 1021003,
     *                   "maxDormFondleMoodCount": 9,
     *                   "maxDormWorkCharacter": 1041002,
     *                   "maxDormWorkCount": 11,
     *                   "maxTouchCharacter": 1031002,
     *                   "maxTouchCount": 145,
     *                   "maxFightCharacter": 1521004,
     *                   "maxFightCount": 682
     *               },
     *               "strongholdMaxGroupName": "渊⼭矿区",
     *               "reviewDraw": {
     *                   "drawAverageCount": 58,
     *                   "drawMaxCount": 92,
     *                   "drawMaxCountCharacterId": 1171004,
     *                   "drawMinCount": 13,
     *                   "drawMinCountCharacterId": 1211003
     *               },
     *               "reviewBossSingle": {
     *                   "bossSingleTotalScore": 53982365,
     *                   "bossSingleMaxScore": 552210,
     *                   "bossSingleMaxScoreBossName": "光辉⾏进者",
     *                   "bossSingleMaxLevelName": "鏖战点"
     *               }
     *           },
     *           "session_id": "tKZY3T7doVlgtScZMRaRkVMlRnkq9ej0hMCBarXG",
     *           "request_id": "4fda8565c46feb37cd9611ae48a00c35e4b51809"
     *       }
     *   }
     * </pre>
     */
    public function queryPlayerReviewDataAction()
    {
        $data = app('logic')->queryPlayerReviewData(app('request')->input());
        return app('logic')->makeJsonpResponse(1, '', $data);
    }

    /**
     * 完成分享任务
     *
     * <pre>
     * params:
     * data{}:
     * remark_before_md: |
     *   登录后调用
     * remark_after_md: |
     * example_request: |
     *   http://<domain>/webapp/sixyear251014/make_finish_share
     * example_response: |
     *   {
     *       "code": 1,
     *       "status": 1,
     *       "msg": "",
     *       "message": "",
     *       "data": {
     *           "session_id": "HidRduG5lGRhUcDSf8vgWJ7CHprqMqErao18UO7Y",
     *           "request_id": "5e4b49e4980b671b9903f84bcb0217813c56d601"
     *       }
     *   }
     * </pre>
     */
    public function makeFinishShareAction()
    {
        app('logic')->makeFinishShare(app('request')->input());
        return app('logic')->makeJsonpResponse(1);
    }

    /**
     * 获取周年回顾奖励
     *
     * <pre>
     * params:
     * data{}:
     * remark_before_md: |
     *   登录后调用
     * remark_after_md: |
     * example_request: |
     *   http://<domain>/webapp/sixyear251014/get_review_reward
     * example_response: |
     *   {
     *       "code": 1,
     *       "status": 1,
     *       "msg": "",
     *       "message": "",
     *       "data": {
     *           "session_id": "HidRduG5lGRhUcDSf8vgWJ7CHprqMqErao18UO7Y",
     *           "request_id": "5e4b49e4980b671b9903f84bcb0217813c56d601"
     *       }
     *   }
     * </pre>
     */
    public function getReviewRewardAction()
    {
        app('logic')->getReviewReward(app('request')->input());
        return app('logic')->makeJsonpResponse(1);
    }

    /**
     * 获取分享奖励
     *
     * <pre>
     * params:
     * data{}:
     * remark_before_md: |
     *   登录后调用
     * remark_after_md: |
     * example_request: |
     *   http://<domain>/webapp/sixyear251014/get_share_reward
     * example_response: |
     *   {
     *       "code": 1,
     *       "status": 1,
     *       "msg": "",
     *       "message": "",
     *       "data": {
     *           "session_id": "TXkneWhItyQNc5M2s5KroNXLVUJTBaZ3XEbXnVQy",
     *           "request_id": "c474cf93f0f9075c9d456b0c37cd33803371cae6"
     *       }
     *   }
     * </pre>
     */
    public function getShareRewardAction()
    {
        app('logic')->getShareReward(app('request')->input());
        return app('logic')->makeJsonpResponse(1);
    }

    /**
     * 获取当前用户分享uid
     *
     * <pre>
     * params:
     * data{}:
     *   share_uid: 分享加密uid
     * remark_before_md: |
     * remark_after_md: |
     * example_request: |
     *   http://<domain>/webapp/sixyear251014/get_share_uid
     * example_response: |
     *   {
     *       "code": 1,
     *       "status": 1,
     *       "msg": "",
     *       "message": "",
     *       "data": {
     *           "share_uid": "a5fb90d9e93f9eb8f6204b4a4134293f",
     *           "session_id": "ky9DNadGOiurdQT9LoTngyV2cyDUhusbYTYvKNk4",
     *           "request_id": "048abb9611e1eae683a13a318d4d4b5507ad546c"
     *       }
     *   }
     * </pre>
     */
    public function getShareUidAction()
    {
        $data = app('logic')->getShareUid(app('request')->input());
        return app('logic')->makeJsonpResponse(1, '', $data);
    }
}
